//
// StoreNuke.Net -  http://www.storenuke.net
// Copyright (c) 2005
// by Robert J Collins ( info@storenuke.net ) of WillowTree Software, Inc. ( http://www.willowtreesoftware.com )
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 
// documentation files (the "Software"), to deal in the Software without restriction, including without limitation 
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and 
// to permit persons to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or substantial portions 
// of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 
// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 
// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
// DEALINGS IN THE SOFTWARE.
//

using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using StoreNuke.StarterKit.Commerce.Components;

namespace StoreNuke.StarterKit.Commerce {

    public abstract class C_Menu : UserControl {
		protected HyperLink hlAdminTools;

        protected DataList MyList;
    
        public C_Menu() {
            this.Init += new EventHandler(Page_Init);
        }

        //*******************************************************
        //
        // The Page_Load event on this page is used to obtain
        // from a database a list of all product categories
        // and databind it to an asp:datalist control.
        //
        // To optimize performance, this user control is output 
        // cached (varying based on the categoryId and selection
        // passed through the querystring.    
        //
        //*******************************************************

        private void Page_Load(object sender, EventArgs e) {

            // Set the curent selection of list
            String selectionId = Request.Params["selection"];

            if (selectionId != null) {
                MyList.SelectedIndex = Int32.Parse(selectionId);
            }

            // Obtain list of menu categories and databind to list control
        	ProductsDB products = new ProductsDB();
        
            MyList.DataSource = products.GetProductCategories(false);
            MyList.DataBind();  

			hlAdminTools.Visible = Security.IsStoreAdmin(Context.User.Identity.Name);
			hlAdminTools.NavigateUrl = "../default.aspx?scid=18";

//			hlCategoryAdmin.Visible = Security.IsStoreAdmin(Context.User.Identity.Name);
//			hlCategoryAdmin.NavigateUrl = "Default.aspx?scid=15&sctl=1";
        }

        private void Page_Init(object sender, EventArgs e) {
            //
            // CODEGEN: This call is required by the ASP.NET Web Form Designer.
            //
            InitializeComponent();
        }

		#region Web Form Designer generated code
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent() {    
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion
    }
}
